<template>
    <div class="mui-numbox" data-numbox-min='1' style=" height: 25px;">
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" :value="initcount" @change="countChange" ref="numberCount" readonly/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>

</template>

<script>
import mui from '../../lib/mui/js/mui.min.js'
export default {
    props: ["initcount", "goodsid"],
    methods: {
        countChange(){
            // console.log(this.$refs.numberCount.value)
            // 每当数量值改变，就把数量同步到购物车中
            this.$store.commit('updateGoodsInfo', { id: this.goodsid, count: this.$refs.numberCount.value})
        }
    },
    created(){
        
    },
    mounted(){
        // 初始化 数字选择框 组件
        mui('.mui-numbox').numbox()

        // 从后台获取数据的时候，注释掉改行，解开 watch
        //  mui('.mui-numbox').numbox().setOption('max',parseInt(this.maxcount))
    },

}

</script>

<style lang="scss" scoped>
</style>